package keter.domain.base;

import javax.persistence.CascadeType;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.validation.constraints.Size;

import keter.domain.Account;

// import org.hibernate.annotations.Table;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * <p>
 * Class : paper.domain.User
 * <p>
 * Descdription: 基础用户 具有教室、学生等公共用户特征的对象，用于继承
 * 
 * @author 顾力行-gulx@neusoft.com
 * @version 1.0.0
 */
@MappedSuperclass
public abstract class BaseUser extends BaseEntity {

    public BaseUser() {
    }

    // 关联主键
    private Account account;
    @OneToOne(cascade = CascadeType.ALL)
    @PrimaryKeyJoinColumn
    public Account getAccount() {
        return account;
    }
    public void setAccount(Account account) {
        this.account = account;
    }

    @Email(message = "电子邮件格式不正确")
    private String email;

    // @NotEmpty
    @Size(max = 11, message = "手机号码格式不正确")
    private String phone;// 手机号

    @NotEmpty(message = "用户名不能为空")
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = decode(name);
    }

    public String getEmail() {
        return email;
    }

    public String getPhone() {
        return phone;
    }

    public void setEmail(String email) {
        this.email = decode(email);
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
   
}